mui.plusReady(function() {

	var YD = 0
	var Task_id = plus.webview.currentWebview().Task_id;
	var Tiele = plus.webview.currentWebview().Tiele;
	var Img = plus.webview.currentWebview().Img;
	var Asrc = plus.webview.currentWebview().Asrc;
	var Asrc = plus.webview.currentWebview().Asrc
	var Newid = plus.webview.currentWebview().Newid;
	var UuId = plus.webview.currentWebview().UuId;
	var Table = plus.webview.currentWebview().Table;
	var flag = ""
	var shareId = ""
	var linkUrl = ""
	var num = 0;
	var numTim = 1;
	$("#IframeScro").attr("src", Asrc)

	
	
	if(Table == 1){
			var showMore = plus.storage.getItem("MoreYd");
			if(showMore) {
				
				$(".More_backdrops").hide()
				YD = 1
				
				} else {
				//没打开
				plus.storage.setItem("MoreYd","打开过阅读红包")
				$(".More_backdrops").show()
				$(".B_XQ_footer").show()
		
				$(".More_backdrops").on("click", function() {
					$(this).hide()
				})
		
				$(".More_footer_img").on("click", function() {
					$(".More_backdrops").hide()
				})
			}
				
	}
	
	



//	if(YD != 0) {
		//把定时器赋值给一个变量

		var int = setInterval(function() {
			numTim++
		}, 1000);
		plus.webview.currentWebview().addEventListener('touchstart', function() {
			num++
			if(num >= 5 && numTim >= 10) {
				numTim = 1
				yd()
			}
		}, false);
//	}

	/*分享*/
	mui.ajax('http://120.76.201.26:8088/task/getTaskInfo?uuid=' + UuId + '&task_id=' + Task_id + '&vid=' + localStorage.vid, {
		dataType: 'json', //服务器返回json格式数据
		type: 'GET', //HTTP请求类型
		crossDomain: 'Boolean',
		timeout: 10000, //超时时间设置为10秒；
		headers: {
			'Content-Type': 'application/json'
		},
		success: function(data) {
			//服务器返回响应，根据响应结果，分析是否登录成功；
			flag = data.data.flag
			linkUrl = data.data.link
			shareId = data.data.shareId
			FX()
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(type);
		}
	});



	function yd() {
		
		if(plus.storage.getItem("next_time") == null){
			plus.storage.setItem("next_time","0")
		}
		
		var timestamp = Date.parse(new Date())/1000;
		var Tim = timestamp - parseFloat( plus.storage.getItem("next_time") )
		
		if(Tim > 0) {
				$(".mui-backdrop_Hb").show()
				$(".H_img").on("click", function() {
					mui.ajax('http://120.76.201.26:8088/task/read?uuid=' + UuId + '&task_id=' + Task_id + '&next_time=' + parseFloat( plus.storage.getItem("next_time") ) + '&vid=' + localStorage.vid, {
						dataType: 'json', //服务器返回json格式数据
						type: 'GET', //HTTP请求类型
						timeout: 10000, //超时时间设置为10秒；
						headers: {
							'Content-Type': 'application/json'
						},
						success: function(data) {
							if(data.code==0){
							var time = data.data.next_time.toString()
							plus.storage.setItem("next_time",time)
							localStorage.reward_rmb = data.data.reward_rmb	
							 $(".mui-backdrop_Hb").hide()
							mui.openWindow({
								url: 'Packet.html',
								id: "Packet",
								extras: {
									Task_id: Task_id,
									Tiele: Tiele,
									Img: Img,
									Asrc: Asrc,
									Newid: Newid,
									UuId: UuId,
									reward_rmb: localStorage.reward_rmb
								}
							});
							
						 }
							
						},
						error: function(xhr, type, errorThrown) {
							
						}
						})
					});

		}
	}

	$(".B_hb_Icon").on("click", function() {
		$(".mui-backdrop_Hb").hide()
	})

	/*遮罩蒙版*/
	$(".B_XQ_footer_Img").on("click", function() {
		$(".mui-backdrop").show()
	})

	$(".B_QX").on("click", function() {
		$(".mui-backdrop").hide()
	})

	$(".B_Title_Ioc").on("click", function() {
		mui.back()

	})

	function FX() {
		var FXurl = 'http://xhy.51kulu.com:94/jump.html?news_id=' + Newid + '&shareId=' + shareId + '&flag=' + flag + '&task_id=' + Task_id

		$(".shareWXHY").on("click", function() {
			plus.pluginutil.shareWX(Tiele, "", FXurl, Img, function(result) {
				mui.toast("分享成功");
			}, function(result) {
				mui.toast("分享失败");
			});
		})

		$(".shareCircle").on("click", function() {
			plus.pluginutil.shareCircle(Tiele, "", FXurl, Img, function(result) {
				mui.toast("分享成功");
			}, function(result) {
				mui.toast("分享失败");
			});
		})

	}

})